package com.tz.online.user.action;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
//保存密码
@WebServlet(urlPatterns="/user/savePassword")
public class SavePassWord extends HttpServlet{

	/**
	 * 
	 */
	private static final long serialVersionUID = 8960778321294778544L;
	
	@Override
	protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		 Cookie[] cookies = req.getCookies();
		 String u = "";
		 String p = "";
		if(null!=cookies){
			for(Cookie c : cookies){
				if("free".equals(c.getName())){
					u=c.getValue().split(":")[0];
					p=c.getValue().split(":")[1];
					break;
				}
			}
		}
		req.setAttribute("username", u);
		req.setAttribute("password", p);
		req.getRequestDispatcher("/jsp/user/login.jsp").forward(req, resp);
	}
}
